Range Method

Wintellect PowerCollections

Collapse imageExpand ImageCollapseAll imageExpandAll imageDropDown imageDropDownHover imageCopy imageCopyHover image
[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

Returns a View collection that can be used for enumerating a range of the items in the bag. Only items that are greater than from and less than to are included. The items are enumerated in sorted order. Items equal to the end points of the range can be included or excluded depending on the fromInclusive and toInclusive parameters.

Namespace: Wintellect.PowerCollections
Assembly:  PowerCollections (in PowerCollections.dll)

Syntax

C#
public OrderedBag<T>.OrderedBag<(Of <T>)>..::View Range(
	T from,
	bool fromInclusive,
	T to,
	bool toInclusive
)
Visual Basic (Declaration)
Public Function Range ( _
	from As T, _
	fromInclusive As Boolean, _
	to As T, _
	toInclusive As Boolean _
) As OrderedBag<(Of <T>)>..::View
Visual C++
public:
OrderedBag<(Of <T>)>..::View^ Range (
	T from, 
	bool fromInclusive, 
	T to, 
	bool toInclusive
)

Parameters

from
T
The lower bound of the range.
fromInclusive
Boolean
If true, the lower bound is inclusive--items equal to the lower bound will be included in the range. If false, the lower bound is exclusive--items equal to the lower bound will not be included in the range.
to
T
The upper bound of the range.
toInclusive
Boolean
If true, the upper bound is inclusive--items equal to the upper bound will be included in the range. If false, the upper bound is exclusive--items equal to the upper bound will not be included in the range.

Return Value

An OrderedBag.View of items in the given range.

Remarks

If from is greater than or equal to to, the returned collection is empty.

Typically, this method is used in conjunction with a foreach statement. For example:

 Copy imageCopy Code
             foreach(T item in bag.Range(from, true, to, false)) {
                // process item
             }
            

If an item is added to or deleted from the bag while the View is being enumerated, then the enumeration will end with an InvalidOperationException.

Calling Range does not copy the data in the tree, and the operation takes constant time.

See Also